package com.zjitc;

import com.zjitc.config.JavaConfigDemo1;
import com.zjitc.config.JavaConfigDemo2;
import com.zjitc.obj.Teacher;
import com.zjitc.obj.User;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/3/6 15:58
 * @description:
 */
public class App3 {

  public static void main(String[] args) {
    //使用注解的方式进行Spring对象的配置的实例
    ApplicationContext context=new AnnotationConfigApplicationContext(JavaConfigDemo2.class);
    User user1=context.getBean("u1",User.class);
    User user2=context.getBean("u1",User.class);
    User user3=context.getBean("u3",User.class);
    if (user1.equals(user2)){
      System.out.println("equal");
    }
    System.out.println(user1);
    System.out.println(user2);

    System.out.println("----------------");
    Teacher t1=context.getBean("teacher",Teacher.class);
    System.out.println(t1);
  }

}
